#include<bits/stdc++.h>

using namespace std;

bool ok(char s[]) {
    int n = strlen(s);
    if (n < 2 || n % 2 == 1)return false;
    int i = 0, j = n - 1;
    while (i < j) {
        if (s[i] != s[j])return false;
        ++i;
        --j;
    }
    return true;
}

int main() {
    freopen("K1.in", "r", stdin);
    char a[150];
    int T;
    cin >> T;
    while (T--) {
        cin >> a;
        while (ok(a)) {
            a[strlen(a) / 2] = 0;
        }
        cout << strlen(a) << endl;
    }
    return 0;
}
